package com.jy.admin.rest.response;

import com.fqgj.common.utils.CollectionUtils;
import com.fqgj.common.utils.StringUtils;
import com.fqgj.common.utils.TimeUtils;
import com.jy.admin.db.entity.BogLogEntity;
import com.jy.admin.db.entity.PendingLogEntity;
import com.jy.admin.rest.request.CheckingListRequest;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2021/12/29
 * Time: 11:22 上午
 */
public class CheckingListResponse {

    private List<CheckingListRequest> list = new ArrayList<>();

    public CheckingListResponse() {
    }

    public CheckingListResponse(List<PendingLogEntity> bogLogEntities) {

        if (CollectionUtils.isEmpty(bogLogEntities)) {
            return;
        }

        bogLogEntities.forEach(bogLogEntity -> {
            String productName =  bogLogEntity.getProductName();
            list.add(new CheckingListRequest()
                    .setCode12(bogLogEntity.getTransctionNo())
                    .setId(bogLogEntity.getId().intValue())
                    .setDt(TimeUtils.toString("yyyy-MM-dd HH:mm:ss", bogLogEntity.getGmtCreate()))
                    .setImgUrl(bogLogEntity.getImgUrl())
                    .setProductName(productName)
                    .setStatus(bogLogEntity.getStatus())
                    .setRequestDetail(bogLogEntity.getRequstDetail())
                    .setResultType(bogLogEntity.getResultType())
                    .setResultContent(bogLogEntity.getResultContent())
                    .setLoanId(bogLogEntity.getLoanId())
                    .setRepaymentDate(bogLogEntity.getRepaymentDate())
            );
        });

    }

    public List<CheckingListRequest> getList() {
        return list;
    }

    public CheckingListResponse setList(List<CheckingListRequest> list) {
        this.list = list;
        return this;
    }
}
